<?php
    $mysqli=new mysqli('localhost','root','root','test');
    if($mysqli->connect_errno){
        die('CONNECT ERROR:'.$mysqli->connect_error);
    }
    $id=$_GET["id"];
    $sql = "SELECT id,username,age FROM user WHERE id=".$id;
    $mysqli_result = $mysqli->query($sql);
    if($mysqli_result && $mysqli_result->num_rows>0){
        $row=$mysqli_result->fetch_assoc();
    }
    //print_r($row);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>Document</title>
</head>
<body>
	<h2>编辑用户</h2>
	<form action="doUser.php?act=edit&id=<?php echo $id;?>" method="post">
	<table border="1" cellspacing="0" cellpadding="0" width="80%">
		<tr>
			<td bgcolor="#ABCDEF">用户名</td>
			<td><input type="text" name="username" value="<?php echo $row['username'];?>" required="required"></input></td>
		</tr>
		<tr>
			<td bgcolor="#ABCDEF">密码</td>
			<td><input type="password" name="password" placeholder="请输入密码" required="required"></input></td>
		</tr>
		<tr>
			<td bgcolor="#ABCDEF">年龄</td>
			<td><input type="number" name="age" min="1" max="125" value="<?php echo $row['age'];?>" placeholder="请输入年龄" required="required"></input></td>
		</tr>
		<tr>
			<td colspan="2"><!-- input:submit --><input type="submit" value="更新用户" /></td>
		</tr>						
	</table>
	</form>
</body>
</html>